<?php


namespace App\Http\Controllers\Common;


use App\Http\Controllers\Controller;
use App\Repositories\Country;
use App\Repositories\Currency;
use App\Repositories\Customer;
use App\Repositories\Dictionary;
use App\Repositories\Port;
use App\Repositories\Transport;
use App\Repositories\Unit;

class SelectController extends Controller
{
    /**
     * @param Dictionary $dictionary
     * @param $code
     * @return \Illuminate\Http\JsonResponse
     * @author luffyzhao@vip.126.com
     */
    public function dictionaries(Dictionary $dictionary, $code){
        return $this->response(
            $dictionary->search($code)
        );
    }

    /**
     * @param Customer $customer
     * @return \Illuminate\Http\JsonResponse
     * @author luffyzhao@vip.126.com
     */
    public function customer(Customer $customer){
        return $this->response(
            $customer->get(['id as code', 'name'])
        );
    }

    /**
     * @param Unit $unit
     * @return \Illuminate\Http\JsonResponse
     * @author luffyzhao@vip.126.com
     */
    public function unit(Unit $unit){
        return $this->response(
            $unit->get(['code', 'name'])
        );
    }

}
